﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveList
{
    List<Character> moveList = new List<Character>();

    public Character GetActor()
    {
        return moveList[0];
    }
    public void Reset()
    {
        //应该使用优先队列，暂时先这样
        moveList.Clear();
        Add();
        if (moveList.Count == 0)
        {
            ResetActionAble();
            Add();
        }
        moveList.Sort((a, b) => -(a.data.speed.CompareTo(b.data.speed)));

    }

    public void Add()
    {
        foreach (Character character in FightSystem.playerTeam.characters)
        {
            if (character.actionable) moveList.Add(character);
        }
        foreach (Character character in FightSystem.enemyTeam.characters)
        {
            if (character.actionable) moveList.Add(character);
        }
    }
    public void ResetActionAble()
    {
        foreach (Character character in FightSystem.playerTeam.characters)
        {
            if (character.alive) character.actionable = true;
        }
        foreach (Character character in FightSystem.enemyTeam.characters)
        {
            if (character.alive) character.actionable = true;
        }
    }
}
